package com.wsd.music.controller;

import com.wsd.music.entity.SongSheet;
import com.wsd.music.service.SongSheetService;
import com.wsd.music.utils.Message;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;

@RestController
@RequestMapping("/songSheet")
public class SongSheetController {

    @Resource
    private SongSheetService service;

    /**
     * 上传歌曲
     * @param songSheet
     * 歌曲描述信息
     * @return
     */
    @PostMapping("/insert")
    public Object addSongSheet(@RequestBody SongSheet songSheet) {
        return service.insert(songSheet) ?
                Message.success("添加成功"):
                Message.error("添加失败");
    }

    @GetMapping("/delete")
    public Object deleteSongSheet(Integer id) {
        System.out.println("正在执行delete方法，song_id=" + id);
        return service.delete(id) ?
                Message.success("删除成功"):
                Message.error("修改失败");
    }

    /**
     * 根据歌单ID查询歌曲
     * 不带歌词
     * @param id
     * @return
     */
    @GetMapping("/selectBySongListId")
    public Object selectBySongListId(Integer id) {
        return service.selectSongsBySongListId(id);
    }

}
